package com.issac.demo.pooled2.commonpool;

import com.issac.demo.pooled2.mypool.ShareBike;
import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

/**
 * @author: ywy
 * @date: 2023-06-28
 * @desc:
 */
public class Test {
    public static void main(String[] args) throws Exception{
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setMaxTotal(5);
        ObjectPool<ShareBike> pool = new GenericObjectPool<>(
                new ShareBikeFactory(),config
        );
        ShareBike shareBike = pool.borrowObject();
        System.out.println(shareBike);
        pool.returnObject(shareBike);

    }
}
